//Keeps track of the Unique number the professor and the time
//THis is a test
import java.util.*;
import java.awt.*;
public class Unique
{
	final String INSTRUCTOR;
	final int UNIQUE;
	String[] days;
	String[] times;
	String[] location;
	int lastIndex;
	
	public Unique()
	{
		UNIQUE=0;
		INSTRUCTOR="Unknown";
		lastIndex=0;
	}
	public Unique(String day, String time)
	{
		UNIQUE=0;
		INSTRUCTOR="NONE";
		days = new String[10];
		times = new String[10];
		days[0] = day;
		times[0] = time;
	}
	// time will look like "0100-0300"
	public Unique(int u,String i, String l, String day, String time)
	{
		location = new String[10];
		days = new String[10];
		times = new String[10];
		lastIndex=0;
		UNIQUE=u;
		INSTRUCTOR=i;
		location[0]=l;
		days[0]=day;
		times[0]=time;
		lastIndex++;
		
	}
	public void addDay(String l,String day,String time)
	{
		location[lastIndex]=l;
		days[lastIndex]=day;
		times[lastIndex]=time;
		lastIndex++;
	}
	public String getInstructor()
	{
		return INSTRUCTOR;
	}
	
	public int getUniqueNumber()
	{
		return UNIQUE;
	}
	
	public static void main(String [] args){
		Unique test = new Unique(12345, "Mike Scott", "UTC 3.104", "MWF", "1300-1400");
		Unique test2 = new Unique(12346, "Mr Penis", "Biology Building", "TTH", "1300-1400");
		System.out.println(test.compare(test2));
	}

	public boolean compare(Unique q)
	{
		int size = this.days.length;
		for(int x=0;x< size && this.days[x] != null;x++)
		{
			String day1 = this.days[x];
			for(int y = 0;y<size && q.days[y] != null;y++)
			{
				String day2 = q.days[y];
				//System.out.println(day1);
				//System.out.println(day2);
				if(day1.contains(day2)||day2.contains(day1))
				{
					String d1Begin = this.times[x].substring(0,4);
					String d1End = this.times[x].substring(5);
					String d2Begin = q.times[y].substring(0,4);
					String d2End = q.times[y].substring(5);
					if(!compareTimes(d1Begin, d1End, d2Begin, d2End))
						return false;
					
				}
				
			}
			
				
		}
		return true;
	}
	
	//returns true if the times work together
	//false if they overlap2
	private boolean compareTimes(String start1, String end1, String start2, String end2){
		if (start1.compareTo(start2) < 0 && end1.compareTo(start2) < 1)
			return true;
		if (start1.compareTo(end2) > -1)
			return true;
		return false;
		
	}
	
	public String toString()
	{
		return UNIQUE+"";
	}
	
	public String [] getTimes(){
		return times;
	}
	
	public String [] getDays(){
		return days;
	}
	
}